import { BaseWindow } from "../../../component/window/BaseWindow";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { StringHelper } from "../../../../com/gengine/utils/StringHelper";
import { MsgManager } from "../../manager/MsgManager";
import { GButton } from "../../../../com/mui/controls/GButton";
import { GTextInput } from "../../../../com/mui/controls/GTextInput";
//class DelAlertWindow
    
    export  class DelAlertWindow extends BaseWindow
    {
        constructor()
        {
            super();
            if (DelAlertWindow._instance) 
            {
                throw new Error("DelAlertWindow单例");
            }
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this.setSize(300, 200);
            this.titleHeight = 28;
            this.title = Language.getString(54164);
            this._bg = ObjCreate.createBg(17, 40, 264, 148, this);
            this._inputTipTxt = ObjCreate.createTextField("", 24, 50, 250, 50, this, new GTextFormat(FontUtil.songtiName, 14, 11661311));
            this._inputTipTxt.wordWrap = true;
            this._inputTipTxt.multiline = true;
            this._inputTipTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._delInput = ObjCreate.createGTextInput(80, 120, 135, 20, this);
            this._delInput.maxChars = 6;
            this._delInput.restrict = "A-z";
            this._delTxt = ObjCreate.createTextField("", 0, 100, 300, 50, this, new GTextFormat(FontUtil.songtiName, 14, 16711680));
            this._delTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._okBtn = ObjCreate.createGButton(Language.getString(54203), 60, 150, 70, 27, this);
            this._okBtn.styleName = "RedButton";
            this._okBtn.name = "ok";
            this._cancelBtn = ObjCreate.createGButton(Language.getString(54204), 160, 150, 70, 27, this);
            this._cancelBtn.name = "cancel";
            this._okBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onOkHandler);
            this._cancelBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onCancelHandler);
            return;
        }

        /* internal  */onOkHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=this._delInput.text.toLocaleLowerCase();
            if (StringHelper.getCharLength(StringHelper.trim(loc1)) == 0 || !(loc1 == "delete")) 
            {
                MsgManager.showRollTipsMsg(Language.getString(54206));
                return;
            }
            if (this._response != null) 
            {
                this._response();
                this._delInput.text = "";
                this.hide();
            }
            return;
        }

        /* internal  */onCancelHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this._delInput.text = "";
            this.hide();
            return;
        }

        public showWindow(arg1: string, arg2: string, arg3: Function): void
        {
            this._response = arg3;
            this._inputTipTxt.htmlText = arg1;
            this._delTxt.htmlText = arg2;
            show();
            return;
        }

        public static get instance(): DelAlertWindow
        {
            if (DelAlertWindow._instance == null) 
            {
                DelAlertWindow._instance = new DelAlertWindow();
            }
            return DelAlertWindow._instance;
        }

        /* internal */ /* var */_bg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_okBtn: GButton;

        /* internal */ /* var */_cancelBtn: GButton;

        /* internal */ /* var */_delInput: GTextInput;

        /* internal */ /* var */_inputTipTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_delTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_response: Function;

        /* internal */ static /* var */_instance: DelAlertWindow;
    }
